<?php

const DISCOUNT=0.8;
$fruit=[
    ['name'=>'香蕉','num'=>'2','price'=>'7.99'],
    ['name'=>'苹果','num'=>'1','price'=>'6.89'],
    ['name'=>'橘子','num'=>'3','price'=>'3.99'],
];
$total=0;
$str='<title>水果订货单</title>';
$str.='<table border="1" cellpadding="1" cellspacing="0">';
$str.='<tr ><td colspan="5">水果订货单</td></tr>';
$str.='<tr><td>商品名称</td><td>购买数量(斤)</td><td>商品价格(元/斤)</td></tr>';
foreach($fruit as $value){
    $str.='<tr>';
    foreach($value as $v){
        $str.='<td>' .$v. '</td>';
    }
    $total2=$value['num']*$value['price'];
    $str.='</tr>';
    $total+=$total2;
    $sum=$total*DISCOUNT;
}
$str.='<tr><td colspan="5">商品折扣：'.DISCOUNT.'</td></tr>';


$str.='<tr><td colspan="5">打折后购买商品总价格为：'.$sum.' 元</td></tr>';
echo $str;
?>
<a href="index.html">点击进入首页</a>
